home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-05-21 | 4.1 KB | 116 lines | [TEXT/ttxt] |
- --<<<-
- --*******************************************************************************
- --* Demo for: ColorPicker
- --* Required files: colrpick.sx
- --* Author: Su Quek - Kaleida Labs, Inc.
- --*-----------------------------------------------------------------------------*
- --* Description: This script demonstrates how to create and use a color
- --* picker.
- --* When you run "colrpick.sxt", you should see a window
- --* with a colorpicker. Click on a colored square in the
- --* colorpicker to change the fill of the window.
- --*
- --* Notes: The colorChanged method MUST be defined as a method of
- --* the ColorPicker's manager
- --*******************************************************************************
-
- module ColorPickerModule
- uses ScriptX
- end
-
- in module ColorPickerModule
-
- --*=============================================================================*
- --* Load required files
- --*=============================================================================*
- -- Load ColorMapShape and ColorPicker
- fileIn theScriptDir name:"colrpick.sx"
-
-
- --*=============================================================================*
- --* Define Demo
- --*=============================================================================*
- class Demo (Window)
- end
-
- --*=============================================================================*
- --* Method name: colorChanged
- --* Class: Demo
- --* Usage: colorChanged self newBrush
- --* newBrush - Brush
- --*-----------------------------------------------------------------------------*
- --* Description: Changes the fill and stroke of the demo window.
- --*=============================================================================*
- method colorChanged self {class Demo} newBrush ->
- (
- self.fill := newBrush
- self.stroke := newBrush
- )
-
- --*=============================================================================*
- --* Method name: init
- --* Class: Demo
- --* Usage: init self
- --*-----------------------------------------------------------------------------*
- --* Description: Creates a 300x300 window.
- --*=============================================================================*
- method init self {class Demo} #rest args ->
- (
- -- Create a 300x300 window
- apply nextMethod self boundary:(new Rect x2:300 y2:300) \
- centered:true \
- name:"Pick a Color" args
- return self
- )
-
- --*=============================================================================*
- --* Method name: afterInit
- --* Class: Demo
- --* Usage: afterInit self
- --*-----------------------------------------------------------------------------*
- --* Description: Makes the color picker and appends it to the demo window.
- --*=============================================================================*
- method afterInit self {class Demo} #rest args ->
- (
- --*=========================================================================*
- --* Create the color picker.
- --*=========================================================================*
- local cp := new ColorPicker manager:self
- cp.x := cp.y := 10
-
- --*=========================================================================*
- --* Add color picker to the demo window and display it.
- --*=========================================================================*
- prepend self cp
- show self
-
- return self
- )
-
-
- --*=============================================================================*
- --* Create a title container
- --*=============================================================================*
- object tc (TitleContainer)
- dir : theScriptDir
- path : "colrpick.sxt"
- name : "Color Picker"
- end
-
- --*=============================================================================*
- --* Create demo
- --*=============================================================================*
- object win (Demo)
- title:tc
- end
-
- --*=============================================================================*
- --* Store module in the title container
- --*=============================================================================*
- append tc (getModule @ColorPickerModule)
- tc.startUpAction := (tc -> load tc[1]
- show win)
-
- close tc
- -->>>
-